require(["./config"], () => {
  require(["template", "cookie"], (template, cookie) => {
    class login {
      constructor() {
        $("#btn").on("click", function() {
          var username = $("#username").val();
          var password = $("#password").val();
          var email = $("#email").val();
          var passwords = $("#passwords").val();
          var locaL = {
            username: username,
            password: password,
            passwords: passwords,
            email: email
          };

          let users = localStorage.getItem("users");
          console.log(users);

          if (users) {
            users = JSON.parse(users);
            // console.log(users);
            users = JSON.push(locaL);
            localStorage.setItem("locaL", JSON.stringify(locaL));
            console.log(users);
          } else {
            let arr = [locaL];
            localStorage.setItem("locaL", JSON.stringify(arr));
          }
          alert("注册成功，即将跳转登录界面");
          window.open("/html/login.html");
          // localStorage.setItem("locaL", 1);
          /* 
          localStorage.setItem("username", username, { expires: 7, path: "/" });
          localStorage.setItem("password", password, { expires: 7, path: "/" });
          localStorage.setItem("passwords", passwords, { expires: 7,
            path: "/"
          });
          localStorage.setItem("email", email, { expires: 7, path: "/" }); */
        });
        console.log(localStorage);
      }
    }
    new login();
  });
});
